package com.janchow.whisper.spi.provider.demo;

import com.alibaba.dubbo.config.annotation.Service;
import com.janchow.whisper.spi.demo.ITalkService;
import org.dwell.smartfd.dao.auth2.domain.SSUser;
import org.dwell.smartfd.dao.auth2.mybatis.SSUserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.UUID;

/**
 * Created by Jange on 2016/5/25.
 */
@Service(version = "1.0.0")
public class TalkService implements ITalkService {

    @Autowired
    private SSUserMapper ssUserMapper;

    @Override
    public void talk(String content) {
        System.out.println("someone talk about : " + content);
    }

    @Override
    public void saveUser() {
        SSUser user = new SSUser();

        user.setEmail("123456789xman@xman.com");
        user.setPassword("12345678");

        user.setId(UUID.randomUUID().toString().replaceAll("-", ""));
//        user.setUserId(Common4J.genUUID());
        user.setUserId("1000000");
        user.setAdmin(true);
        user.setEnabled(true);
        user.setExpired(false);
        user.setGender(1);
        user.setCreationTime(System.currentTimeMillis());
        user.setCreationUser("JO-SYS-ADMIN");

        int ret = ssUserMapper.insert(user);
        if(ret == 1) {
            throw new RuntimeException("whatsapp");
        }
        System.out.println("insert ret value : " + ret);
    }
}
